<template>
  <a-modal
    title="文件评审"
    :visible="visible"
    class="pub-middle-dialog"
    :confirm-loading="loading"
    @ok="handleOk"
    @cancel="visible=false"
  >
    <searchData
      :search-data="searchArr"
      @search="search"
    />
    <a-table
      v-loading="loading"
      :pagination="false"
      :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange ,type:'radio'}"
      :columns="columns"
      :data-source="tableData"
      row-key="id"
    >
      <span
        slot="num"
        slot-scope="text, record, index"
      >{{ index + 1 }}</span>
    </a-table>
    <pagination
      v-model="pageNo"
      :total="totalSize"
      :page-size.sync="pageSize"
      @change="handlePageChange"
      @showSizeChange="showSizeChange"
    />
  </a-modal>
</template>
<script>
import { reviewList } from '@/api/material/procurement/review'

export default {
	name:'a'+Date.now(),
    data: function() {
        return {
            loading: false,
            pageNo: 1,
            queryParam: {},
            pageSize: 10,
            totalSize: 0,
            visible: false,
            tableData: [],
            columns: [
                {
                    title: '序号',
                    scopedSlots: { customRender: 'num' }
                },
                {
                    title: '物资招标文件评审编码',
                    dataIndex: 'fileCode',
                    ellipsis: true
                },
                {
                    title: '招标名称',
                    dataIndex: 'materialPurchaseApplyName',
                }
            ],
            searchArr: [
                {
                    name: '物资招标文件评审编码',
                    value: 'fileCode',
                    type: 'input'
                }
            ],
            selectedRowKeys: [],
            selectRow: null
        }
    },
    methods: {
        open: function() {
            this.visible = true
            this.search()
            this.selectedRowKeys = []
            this.selectRow = null
        },
        handleOk: function() {
            this.visible = false
            this.$emit('getRow', this.selectRow)
        },
        async list(params) {
            let searchData = Object.assign({
                pageSize: this.pageSize,
                pageNo: this.pageNo,
                auditStatus: 'PAST',
                collect: this.$userType() !== 'PD',
                quote: 1
            }, params, this.queryParam)
            this.loading = true
            let res = await reviewList(searchData)
            this.loading = false
            if (res.code === 200 || res.data.code === 200) {
                this.tableData = res.data
                this.totalSize = res.totalSize
            }
        },
        search(val) {
            this.pageNo = 1
            this.queryParam = val

            this.list(val)
        },
        handlePageChange(pageNo, pageSize) {
            this.pageNo = pageNo
            this.list()
        },
        showSizeChange(pageNo, pageSize) {
            this.pageNo = 1
            this.pageSize = pageSize
            this.list()
        },
        onSelectChange(selectedRowKeys, selectedRows) {
            this.selectRow = selectedRows[0]
            this.selectedRowKeys = selectedRowKeys
        }
    }
}
</script>
